package com.example.myblog.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.time.LocalDateTime;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.DateFormat;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

/**
 * <p>
 * 博客基本信息
 * </p>
 *
 * @author 叶兴
 * @since 2022-09-29
 */
@Data
@TableName("blog_message")
@Document(indexName = "blog_message")
public class BlogMessage implements Serializable {

    private static final long serialVersionUID = 1L;

    @TableId("id")
    @Id
    private String id;

    /**
     * 作者
     */
    @TableField("user_name")
    @Field(type = FieldType.Text,copyTo = "all",searchAnalyzer = "ik_max_word")
    private String userName;

    /**
     * 文章标题
     */
    @TableField("blog_title")
    @Field(type = FieldType.Text,copyTo = "all",searchAnalyzer = "ik_smart")
    private String blogTitle;

    /**
     * 创建时间
     */
    @TableField("blog_created")
    @JsonFormat(shape = JsonFormat.Shape.STRING,pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    @Field(type = FieldType.Date,format = DateFormat.date_hour_minute_second,pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime blogCreated;

    /**
     * 评论数
     */
    @TableField("blog_comments")
    private Integer blogComments;

    /**
     * 点赞数
     */
    @TableField("blog_likes")
    private Integer blogLikes;

    /**
     * 博客状态,1表示已发布，0表示已删除
     */
    @TableField("blog_state")
    private Integer blogState;

    /**
     * 浏览量
     */
    @TableField("blog_read")
    private Integer blogRead;

    /**
     * 文章所属类型
     */
    @TableField("blog_category")
    @Field(type = FieldType.Text)
    private String blogCategory;

    @TableField("blog_description")
    @Field(type = FieldType.Text,copyTo = "all",searchAnalyzer = "ik_max_word")
    private String blogDescription;
    /**
     * 文章图片
     */
    @TableField("blog_image")
    private String blogImage;

}
